package com.ebelter.nb.adapters;


import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

import com.ebelter.btcomlib.utils.AppUtils;
import com.ebelter.btcomlib.views.CombinView8;
import com.ebelter.nb.R;
import com.ebelter.nb.beans.TrendScaleAdaperBean;


import java.util.List;

public class TrendScaleFragmentAdaper extends RecyclerView.Adapter<TrendScaleFragmentAdaper.ViewHolder>{




    private Context mContext;

    private List<TrendScaleAdaperBean> datas;

    public TrendScaleFragmentAdaper(Context mContext) {
        this.mContext = mContext;
    }

    public void setDatas(List<TrendScaleAdaperBean> datas){
        this.datas=datas;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = View.inflate(mContext, R.layout.trendscalefragment_item_ly,null);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {

        holder.combinView8.setTitle(1,datas.get(position).title1);
        holder.combinView8.setTitle(2,datas.get(position).title2);
        holder.combinView8.setTitle(3,datas.get(position).title3);
        holder.combinView8.setTitle(4,datas.get(position).title4);
        holder.combinView8.setImaSrc(datas.get(position).srcRes);

    }

    @Override
    public int getItemCount() {
        return datas==null?0:datas.size();
    }

    //ViewHolder，需要继承RecyclerView.ViewHolder
    static class ViewHolder extends RecyclerView.ViewHolder{
        private CombinView8 combinView8;
        ViewHolder(View itemView) {
            super(itemView);
            combinView8 = itemView.findViewById(R.id.trendscalefragment_cb8);
            if (AppUtils.en.equals(AppUtils.getLocalStr())){
                combinView8.setTitleSize(1,12);
            }
        }
    }
}
